package com.ruoyi.web.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.system.domain.Product;
import com.ruoyi.system.service.IProductService;
import com.ruoyi.web.core.config.sqlYz.LoginRequired;
import com.ruoyi.web.domian.sqlReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


//产品api
@Controller
@RequestMapping("/pdt_sql")
public class sqlPdtController extends BaseController {


    @Autowired
    private IProductService IProductService;
//    查找产品  公司id

    @PostMapping("/select_cpId")
    @LoginRequired
    @ResponseBody
    public sqlReturn getPctSql(Product product){
        try {
            System.out.println(product+"\t");
            List<Product> list = IProductService.selectProductList(product);
            if(list.size()==0){
                return new sqlReturn(null,"暂无产品",500);
            }
            return new sqlReturn(list,"查询成功",200);
        } catch (AssertionError e){
            return new sqlReturn(null,"网络异常",500);
        }

    }

}
